package qianting.news.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import qianting.news.auth.entity.NewsUser;

@Mapper
public interface NewsUserMapper extends BaseMapper<NewsUser> {

    //通过用户名name查询password和id
    @Select("SELECT id,salt,password from ap_user where name = #{name}")
    NewsUser getPasswordAndId(String name);

    //保存id,用户名,密码和盐
    @Insert("INSERT INTO ap_user (salt,name,password) values (#{salt},#{name},#{password})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    boolean saveUser(NewsUser newsUser);

}
